a = input()
z = ['(', '[', '{', '<']
x = [')', ']', '}', '>']
c = [0, 0, 0, 0]
s = ''
flag = True
for i in range(len(a)):
    for k in range(4):
        if a[i] == z[k]:
            c[k] += 1
            s = s + z[k]
            break
        elif a[i] == x[k]:
            c[k] -= 1
            if len(s) == 0:
                continue
            if s[-1] == z[k]:
                s = s[:-1]
            else:
                flag = False
                
            break
    for j in range(4):
        if c[j] < 0:
            flag = False
            break
if len(s) > 0:
    flag = False
if flag is True:
    print('True')
else:
    print('False')
